import { defineStore } from 'pinia'

interface User {
  username: string
  nickname?: string
  avatar?: string
  token?: string
}

export const useUserStore = defineStore('user', {
  state: () => ({
    currentUser: null as User | null,
    isLoggedIn: false
  }),
  
  getters: {
    user: (state) => state.currentUser,
    loggedIn: (state) => state.isLoggedIn
  },
  
  actions: {
    setUser(user: User) {
      this.currentUser = user
      this.isLoggedIn = !!user
    },
    
    clearUser() {
      this.currentUser = null
      this.isLoggedIn = false
    }
  }
}) 